﻿//
package ICode.name.ui {
	//
	import flash.display.Bitmap ;
	import flash.display.BitmapData ;
	import flash.geom.Rectangle ;
	import flash.events.Event ;
	//
	public class BigScrollBitmap extends Bitmap {
		//
		private var m_obText :TransferText ;
		private var m_nWidth:int = 0 ;
		private var m_nHeight:int = 0 ;
		private var m_obData:BigBitmapData ;
		//
		public function BigScrollBitmap(obj:BitmapData = null, pixelSnapping:String = "auto", smoothing:Boolean = false){
			super(obj,pixelSnapping , smoothing );
			m_obText = new TransferText(this );
		}
		//∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥
		public function get textField():TransferText{return m_obText };
		//∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥尺寸变更函数
		public function setSize(width:int, height:int ):void{
			super.scrollRect = new Rectangle(0,0,width,height );
			if(m_obData){
				m_obData.width = width ;
				m_obData.height = height ;
				m_obText.width = width ;
				m_obText.height = height ;
				m_obText.maxScrollV = m_obData.dataHeight - height ;
				m_obText.maxScrollH = m_obData.dataWidth - width ;
				m_obText.dispatchEvent(new Event(Event.CHANGE)) ;
				if(m_obData.ofsetX + width > m_obData.dataWidth ){
					scrollH = m_obData.dataWidth - width ;
				}
				if(m_obData.ofsetY + height > m_obData.dataHeight ){
					scrollV = m_obData.dataHeight - height ;
				}
			}
			m_nWidth = width ;
			m_nHeight = height ;
		}
		//∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥宽度覆盖函数
		public override function set width(value:Number):void {
			setSize(value , m_nHeight );
		}
		//∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥高度覆盖函数
		public override function set height(value:Number):void{
			setSize(m_nWidth, value );
		}
		//∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥滚动设置函数
		public function set scrollV(value:int):void {
			if(m_obData){
				m_obData.scroll(m_obData.ofsetX,value );
			}
		}
		//∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥水平滚动函数
		public function set scrollH(value:int):void {
			if(m_obData){
				m_obData.scroll(value ,m_obData.ofsetY);
			}
		}
		//∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥
		public override function set bitmapData(obj:BitmapData):void{
			super.bitmapData = obj ;
			m_obData = obj as BigBitmapData ;
			if(m_obData!=null) {
				m_obText.numLines = m_obData.dataHeight;
				m_obText.textWidth = m_obData.dataWidth ;
			}
		}
		//∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥
	}
}
	//
	import flash.text.TextField ;
	import ICode.name.ui.BigScrollBitmap ;
	//
	class TransferText extends TextField{
		//
		private var m_nMaxScrollV:int =0;
		private var m_nScrollV:int = 0 ;
		private var m_nNumberLines:int = 0 ;
		private var m_nScrollH:int = 0;
		private var m_nMaxScrollH:int = 0;
		private var m_nTextWidth:int = 0 ;
		private var m_obTarget:BigScrollBitmap ;
		//
		public function TransferText(obj:BigScrollBitmap ){
			m_obTarget = obj ;
		}
		//∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥
		public function set maxScrollV(value:int):void{m_nMaxScrollV = value };
		public override function get maxScrollV():int{return m_nMaxScrollV } ;
		public override function set scrollV(value:int):void{
			m_nScrollV = value ;
			if(m_obTarget!=null)m_obTarget.scrollV = value ;
		}
		public override function get scrollV():int{return m_nScrollV } ;
		public function set numLines(value:int):void{m_nNumberLines = value };
		public override function  get numLines():int{return m_nNumberLines } ;
		//∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥
		public function set maxScrollH(value:int):void{m_nMaxScrollH = value };
		public override function get maxScrollH():int{return m_nMaxScrollH } ;
		public override function set scrollH(value:int):void {
			m_nScrollH = value ;
			if(m_obTarget!=null)m_obTarget.scrollH = value ;
		}
		public override function get scrollH():int{return m_nScrollH } ;
		public function set textWidth(value:Number):void{m_nTextWidth = value };
		public override function  get textWidth():Number{return m_nTextWidth } ;
		//∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥
	}